package com.site.web.controller.war;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.site.common.annotation.Log;
import com.site.common.core.controller.BaseController;
import com.site.common.core.domain.AjaxResult;
import com.site.common.enums.BusinessType;
import com.site.war.domain.SiteFiveLimitWarning;
import com.site.war.service.ISiteFiveLimitWarningService;
import com.site.common.utils.poi.ExcelUtil;
import com.site.common.core.page.TableDataInfo;

/**
 * 五限位预警Controller
 *
 * @author site
 * @date 2023-10-13
 */
@RestController
@RequestMapping("/war/five")
public class SiteFiveLimitWarningController extends BaseController
{
    @Autowired
    private ISiteFiveLimitWarningService siteFiveLimitWarningService;

    /**
     * 查询五限位预警列表
     */
    @PreAuthorize("@ss.hasPermi('war:five:list')")
    @GetMapping("/list")
    public TableDataInfo list(SiteFiveLimitWarning siteFiveLimitWarning)
    {
        startPage();
        List<SiteFiveLimitWarning> list = siteFiveLimitWarningService.selectSiteFiveLimitWarningList(siteFiveLimitWarning);
        return getDataTable(list);
    }

    /**
     * 导出五限位预警列表
     */
    @PreAuthorize("@ss.hasPermi('war:five:export')")
    @Log(title = "五限位预警", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SiteFiveLimitWarning siteFiveLimitWarning)
    {
        List<SiteFiveLimitWarning> list = siteFiveLimitWarningService.selectSiteFiveLimitWarningList(siteFiveLimitWarning);
        ExcelUtil<SiteFiveLimitWarning> util = new ExcelUtil<SiteFiveLimitWarning>(SiteFiveLimitWarning.class);
        util.exportExcel(response, list, "五限位预警数据");
    }

    /**
     * 获取五限位预警详细信息
     */
    @PreAuthorize("@ss.hasPermi('war:five:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(siteFiveLimitWarningService.selectSiteFiveLimitWarningById(id));
    }

    /**
     * 新增五限位预警
     */
    @PreAuthorize("@ss.hasPermi('war:five:add')")
    @Log(title = "五限位预警", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SiteFiveLimitWarning siteFiveLimitWarning)
    {
        return toAjax(siteFiveLimitWarningService.insertSiteFiveLimitWarning(siteFiveLimitWarning));
    }

    /**
     * 修改五限位预警
     */
    @PreAuthorize("@ss.hasPermi('war:five:edit')")
    @Log(title = "五限位预警", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SiteFiveLimitWarning siteFiveLimitWarning)
    {
        return toAjax(siteFiveLimitWarningService.updateSiteFiveLimitWarning(siteFiveLimitWarning));
    }

    /**
     * 删除五限位预警
     */
    @PreAuthorize("@ss.hasPermi('war:five:remove')")
    @Log(title = "五限位预警", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(siteFiveLimitWarningService.deleteSiteFiveLimitWarningByIds(ids));
    }
}
